package network

// NetworkingConfig 表示容器每个接口的网络配置
// NetworkingConfig represents the container's networking configuration for each of its interfaces
// 携带“docker run”和“docker network connect”命令中指定的网络配置
// Carries the networking configs specified in the `docker run` and `docker network connect` commands
type NetworkingConfig struct {
	//每个连接网络的端点配置
	// Endpoint configs for each connecting network
	EndpointsConfig map[string]*EndpointSettings
}

// EndpointSettings存储网络端点详细信息
// EndpointSettings stores the network endpoint details
type EndpointSettings struct {
	// Configurations
	IPAMConfig *EndpointIPAMConfig
	Links      []string
	Aliases    []string
	// Operational data
	NetworkID           string
	EndpointID          string
	Gateway             string
	IPAddress           string
	IPPrefixLen         int
	IPv6Gateway         string
	GlobalIPv6Address   string
	GlobalIPv6PrefixLen int
	MacAddress          string
	DriverOpts          map[string]string
}

// EndpointIPAMConfig represents IPAM configurations for the endpoint
type EndpointIPAMConfig struct {
	IPv4Address  string   `json:",omitempty"`
	IPv6Address  string   `json:",omitempty"`
	LinkLocalIPs []string `json:",omitempty"`
}

// Address 代表IP地址
// Address represents an IP address
type Address struct {
	Addr      string
	PrefixLen int
}

// IPAM represents IP Address Management
type IPAM struct {
	Driver string
	// Per network IPAM driver options
	Options map[string]string
	Config  []IPAMConfig
}

// IPAMConfig represents IPAM configurations
type IPAMConfig struct {
	Subnet     string            `json:",omitempty"`
	IPRange    string            `json:",omitempty"`
	Gateway    string            `json:",omitempty"`
	AuxAddress map[string]string `json:"AuxiliaryAddresses,omitempty"`
}

// ConfigReference 指定提供网络配置的源
// ConfigReference specifies the source which provides a network's configuration
type ConfigReference struct {
	Network string
}

// PeerInfo 表示覆盖网络的一个对等体
// PeerInfo represents one peer of an overlay network
type PeerInfo struct {
	Name string
	IP   string
}

// ServiceInfo 用服务的任务列表表示服务参数
// ServiceInfo represents service parameters with the list of service's tasks
type ServiceInfo struct {
	VIP          string
	Ports        []string
	LocalLBIndex int
	Tasks        []Task
}

// Task 携带一个后端任务的信息
// Task carries the information about one backend task
type Task struct {
	Name       string
	EndpointID string
	EndpointIP string
	Info       map[string]string
}
